package com.neusoft.boot32.dibuy.entity.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @program: springboot32
 * @description:
 * @author: Jingdi.Duan ,duanjingdi@msn.com
 * @create: 2024-07-11 11:40
 **/

@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    public     MyMetaObjectHandler(){
        System.out.println("MyMetaObjectHandler.MyMetaObjectHandler");
    }

    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("开始插入填充...");
        this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {

        log.info("开始更新填充...");
        this.setFieldValByName( "lastModifiedTime" , LocalDateTime.now()  ,metaObject );
    }
}